package Supermercado.Pruebas.Menus;

import javax.microedition.lcdui.*;

import DepositoMIDlet;
import Supermercado.Pruebas.Alertas.*;
import Supermercado.Pruebas.SeleccionGrupos.*;


public class Menu extends List implements CommandListener {

    private Command exit = new Command("Salir", Command.EXIT, 0);

    public Menu(String title) {
        super(title, List.IMPLICIT);
        append("Formularios", null);
        append("Listas", null);
        append("TextBox", null);
        append("Alert", null);
        append("Alert con Command", null);
        append("Ticker", null);
        addCommand(exit);
        setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d) {
        if(c == exit){
            DepositoMIDlet.midlet.destroyApp(true);
            DepositoMIDlet.midlet.notifyDestroyed();
        }
        if (c == List.SELECT_COMMAND) {
            int index = getSelectedIndex();
            switch (index) {
                case 0:
                    DepositoMIDlet.midlet.display.setCurrent(new MenuFormulario());
                    break;
                case 1:
                    DepositoMIDlet.midlet.display.setCurrent(new MenuListas());
                    break;
                case 2:
                    DepositoMIDlet.midlet.display.setCurrent(new TextBoxEjemplo("TextBox Ejemplo"));
                    break;
                case 3:
                    DepositoMIDlet.midlet.display.setCurrent(new AlertaEjemplo());
                    break;
                case 4:
                    DepositoMIDlet.midlet.display.setCurrent(new AlertCommandExample("Alert con Command"));
                    break;
                case 5:
                    DepositoMIDlet.midlet.display.setCurrent(new TickerExample("Ticker"));
                    break;
            }
        }
    }
}
